package com.logistics.delivery.entity.model;

import com.logistics.delivery.entity.domain.Delivery;
import com.logistics.utils.tool.DateUtils;
import com.logistics.utils.tool.StringUtils;
import lombok.Data;

import java.math.BigDecimal;

@Data
public class DeliveryRow {

    private String id;

    private String code;

    private String pick;

    private String priority;

    private String agv;

    private String type;

    private String status;

    private String startStation;

    private String endStation;

    private String agvType;

    private BigDecimal unloadHeight;

    private BigDecimal unloadDownloadHeight;

    private BigDecimal loadHeight;

    private BigDecimal containHeight;

    private String creator;

    private String createTime;

    private String updater;

    private String updateTime;

    public DeliveryRow(){}

    public DeliveryRow(Delivery delivery){
        this.id  = delivery.getId().toString();
        this.code  = delivery.getCode();
        this.pick = StringUtils.isNotNull(delivery.getPick()) ? delivery.getPick().toString() : null;
        this.priority = StringUtils.isNotNull(delivery.getPriority()) ? delivery.getPriority().toString() : null;
        this.agv  = delivery.getAgv();
        this.type = delivery.getType();
        this.status = StringUtils.isNotNull(delivery.getStatus()) ? delivery.getStatus().toString() : null;
        this.startStation = delivery.getStartStation();
        this.endStation = delivery.getEndStation();
        this.agvType = delivery.getAgvType();
        this.unloadHeight = delivery.getUnloadHeight();
        this.unloadDownloadHeight = delivery.getUnloadDownloadHeight();
        this.loadHeight = delivery.getLoadHeight();
        this.containHeight = delivery.getContainHeight();
        this.creator = delivery.getCreator();
        this.createTime = DateUtils.dateToStringFormat(delivery.getCreateTime(), DateUtils.YYYY_MM_DD_HH_MM_SS);
        this.updater = delivery.getUpdater();
        this.updateTime = DateUtils.dateToStringFormat(delivery.getUpdateTime(), DateUtils.YYYY_MM_DD_HH_MM_SS);
    }

    public static DeliveryRow build(Delivery delivery){
        return new DeliveryRow(delivery);
    }
}
